'''
draw a graph of agent using the porter stemming algorithm and eliminating stop 
words.
of accuracy opposed to number of features.
'''

from agent1 import Agent1
from one_agent_accurcy import AgentTester
from text_example import createRealDatasets
from numpy import arange
import matplotlib.pyplot as plt
import numpy as np


datasets = createRealDatasets()
results = {}
sizes = arange(start=20,stop = 320, step=20)
    
for name, data in datasets.items():
    
    results[name] = {}
            
    for number_of_features in sizes:
        
        class a(Agent1):
            pass
        a.set(number_of_features)
        tester = AgentTester()
        r = tester.run(data, a, 1, 30, 10)
        results[name][number_of_features] = r

results['avarge']={}
for s in sizes:
    results['avarge'][s] = 0.0
    for test in results:
        results['avarge'][s] += results[test][s]
    results['avarge'][s] /= len(results)
            
for name, test in results.items():
    
    xs = sizes
    ys = map(lambda x : test[x], sizes)
    f = plt.figure()
    f.suptitle(name)
    ax = f.add_subplot(111)

    ax.set_xlabel('#features')
    ax.set_ylabel('accuracy')
    ax.plot(xs, ys, '--o', ms=10, lw=3, mfc='red')


plt.show()
        
